{extend name="template/base" /}
{block name="nav"}{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:url('Pub/paymentDeploy')}" >

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">支付方式：</label>
            <div class="formControls col-xs-4 col-sm-4">
                <select name="pay_id" id="pay_id" class="select">
                    <option value="">请选择更改配置的支付方式</option>
                    {volist name="info" id="vo"}
                        <option value="{$vo['id']}">{$vo.remark}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="wxpay" style="display: none"> 
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">微信APPID：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text" class="input-text wxappid" style="width: 300px;" value="" placeholder="请输入微信Appid" name="wxappid" >
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">微信MCHID：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <textarea style="width: 300px;height: 55px;" class="input-text mchid"  name="mchid"></textarea>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">微信APPSECRET：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <textarea style="width: 300px;height: 55px;" class="input-text appsecret"  name="appsecret"></textarea>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">微信KEY：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <textarea style="width: 300px;height: 55px;" class="input-text wx_key"  name="wx_key"></textarea>
                </div>
            </div>
        </div>

        <div class="alipay" style="display: none">
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">支付宝Appid：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text" class="input-text appid" style="width: 300px;" value="" placeholder="请输入支付宝Appid" name="appid" >
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">支付宝我们自己的私钥：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <textarea style="width: 800px;height: 300px;" class="input-text private_key"  name="private_key"></textarea>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">支付宝的公钥：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <textarea style="width: 800px;height: 200px;" class="input-text public_key"  name="public_key"></textarea>
                </div>
            </div>
            
        </div>
        
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius ml-5" >确定</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="__LIB__/My97DatePicker/WdatePicker.js"></script>
<script src="__STATIC__/js/mobileFix.mini.js?v=ad62f13"></script>
<script src="__STATIC__/js/exif.js?v=dd609b9"></script>
<script src="__STATIC__/js/lrz.js?v=3d33fcf"></script>
<script>
$('#pay_id').change(function(){
            var way=$(this).val();
            if(way=='2' || way=='3'){
                $('.alipay').show(500);
                $('.wxpay').hide();
            }
            if(way=='1'){
                $('.wxpay').show(500);
                $('.alipay').hide();
            }
            $.ajax({
                method:"post",
                url:"{:Url('Pub/configInfo')}",
                data:{
                    id:way
                },
                dataType:"json",
                async:true,
                success:function(result){
                    console.info(result);
                    if(result){

                        if(way=='1'){
                            $('.mchid').val(result.data.mchid);
                            $('.appsecret').val(result.data.appsecret);
                            $('.wx_key').val(result.data.wx_key);
                            $('.wxappid').val(result.data.appid);
                        }else {
                            $('.public_key').html(result.data.public_key);
                            $('.private_key').html(result.data.private_key);
                            $('.appid').val(result.data.appid);
                        }
                    }else{

                    }
                }
            });
        });

    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $("#form").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            callback:function(ret){
                if (ret.code == 0) {
                    parent.layer.msg('成功', {icon: 1, time: 2000});
                    window.location.reload();
                }else{
                    layer.msg(ret.msg,{icon: 5,time:1000});
                }
                //ajax_progress(ret);
                
            }
        });
    })
</script>
{/block}